/**
*      author: Y_Yao
*      created: 2024-12-03 19:50:16
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 20 + 7;
const int M = 1e7 + 7;
int a[N];
int n,k;
int ret;

bool isprime(int x)
{
    if(x == 1) return false;
    for(int i = 2;i * i <= x;i++)
    {
        if(x % i == 0)
        {
            return false;
        }
    }
    //cout << x << endl;
    return true;
}

void dfs(int step,int sum,int start)
{
    if(step == k)
    {
        if(isprime(sum)) ret++;
        return;
    }

    for(int i = start;i <= n;i++)
    {
        dfs(step + 1,sum + a[i],i + 1);
    }

}

void solve()
{
    cin >> n >> k;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }

    dfs(0,0,1);
    cout << ret << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}